package seismosurfer.data;

import java.io.Serializable;

/**
 * A Data Transfer Object that contains metadata information for a document stored in
 * the database.
 */
public class DocumentMetaData implements Serializable {
    
    private static final long serialVersionUID = 3927244744472641489L;

    private long documentID;

    private String description;

    private String contentLength;

    private String mimeType;

    // source = srcType://srcLocation/srcName
    private String source;

    private String sourceName;

    private String sourceType;

    private String info;

    /**
     * Default constructor.
     */
    public DocumentMetaData() {

    }

    /**
     * Gets the source type. This is a part of the <code>source</code>
     * metadata, which has the following format:
     * <code>source = srcType://srcLocation/srcName.</code>
     * 
     * @return a string with the source type or an empty string.
     */
    public String getSourceType() {
        return sourceType;
    }

    /**
     * Gets the source name. This is a part of the <code>source</code>
     * metadata, which has the following format:
     * <code>source = srcType://srcLocation/srcName.</code>
     * 
     * @return a string with the source name or an empty string.
     */
    public String getSourceName() {
        return sourceName;
    }

    /**
     * Gets additional information associated with this document.
     * 
     * @return a string with additional information for this document or an
     *         empty string.
     */
    public String getInfo() {
        return info;
    }

    /**
     * Gets document ID.
     * 
     * @return the document ID
     */
    public long getDocumentID() {
        return documentID;
    }

    /**
     * Gets a description for this document.
     * 
     * @return a string with a description for this document or an empty string.
     */
    public String getDescription() {
        return description;
    }

    /**
     * Gets the length in bytes of this document.
     * 
     * @return a string with the length (in bytes) of this document, an empty
     *         string or a ?.
     */
    public String getContentLength() {
        return contentLength;
    }

    /**
     * Gets the MIME type.
     * 
     * @return a string containing the mime type of this document or an empty
     *         string.
     */
    public String getMimeType() {
        return mimeType;
    }

    /**
     * Gets all the source metadata. It has the following format: <code>source =
     * srcType://srcLocation/srcName.</code>
     * 
     * @return a string with the source information.
     */
    public String getSource() {
        return source;
    }

    /**
     * Sets document ID.
     * 
     * @param docid
     *            the document ID
     */
    public void setDocumentID(long docid) {
        this.documentID = docid;
    }

    /**
     * Sets the description.
     * 
     * @param desc
     *            a string describing this document.
     */
    public void setDescription(String desc) {
        if (desc == null) {
            desc = "-";
        }
        this.description = desc;
    }

    /**
     * Sets the document`s length in bytes.
     * 
     * @param contentLength
     *            a string containing this document`s length.
     */
    public void setContentLength(String contentLength) {
        if (contentLength == null) {
            contentLength = "?";
        }

        this.contentLength = contentLength;
    }

    /**
     * Sets the MIME type.
     * 
     * @param mimeType
     *            a string that contains the MIME type of this document.
     */
    public void setMimeType(String mimeType) {

        if (mimeType == null) {
            mimeType = "-";
        }

        this.mimeType = mimeType;
    }

    /**
     * Sets the source information for this document. The source information
     * should be in this form:
     * <code>source = srcType://srcLocation/srcName.</code>
     * 
     * @param source
     *            a string containing the source information.
     */
    public void setSource(String source) {
        this.source = source;
    }

    /**
     * Sets source name. The source name is part of the source information which
     * has this form: <code>source = srcType://srcLocation/srcName.</code>
     * 
     * @param srcName
     *            a string containing the source name.
     */
    public void setSourceName(String srcName) {
        this.sourceName = srcName;
    }

    /**
     * Sets additional information associated with this document.
     * 
     * @param info
     *            a string containing the information.
     */
    public void setInfo(String info) {
        if (info == null) {
            info = "-";
        }
        this.info = info;
    }

    /**
     * Sets source type. The source type is part of the source information which
     * has this form: <code>source = srcType://srcLocation/srcName.</code>
     * 
     * @param srcType
     *            a string containing the source type.
     */
    public void setSourceType(String srcType) {
        this.sourceType = srcType;
    }

}
